package myServlet;

import java.io.IOException;


import java.io.PrintWriter;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ConfigDemoServlet extends HttpServlet {
	String servletName = null;
	ServletConfig config = null;
	String email = null;
	String telephone = null;

	public void init() {
		ServletContext sc=getServletContext();
		config = getServletConfig();
		servletName = config.getServletName();
		sc.setAttribute("email","telephone");
		email = config.getInitParameter("email");
		telephone = config.getInitParameter("telephone");
	}

	public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=gb2312");
		PrintWriter out = response.getWriter();
		out.println("<html><body>");
		out.println("Servlet 鍚嶇О锛�" + servletName + "<br>");
		out.println("Email 鍦板潃锛�" + email + "<br>");
		out.println("鐢佃瘽锛�" + telephone);
		out.println("</body></html>");
	}
}
